package com.heima.wemedia.service.service.impl;


import com.heima.wemedia.service.dao.WmNewsMaterialDao;
import com.heima.model.wemedia.entity.WmNewsMaterial;
import com.heima.wemedia.service.service.WmNewsMaterialService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 文章素材关联表(WmNewsMaterial)表服务实现类
 *
 * @author makejava
 * @since 2022-04-12 19:21:27
 */
@Service("wmNewsMaterialService")
public class WmNewsMaterialServiceImpl implements WmNewsMaterialService {
    @Resource
    private WmNewsMaterialDao wmNewsMaterialDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public WmNewsMaterial queryById(Long id) {
        return this.wmNewsMaterialDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param wmNewsMaterial 实例对象
     * @return 实例对象
     */
    @Override
    public WmNewsMaterial insert(WmNewsMaterial wmNewsMaterial) {
        this.wmNewsMaterialDao.insert(wmNewsMaterial);
        return wmNewsMaterial;
    }

    /**
     * 修改数据
     *
     * @param wmNewsMaterial 实例对象
     * @return 实例对象
     */
    @Override
    public WmNewsMaterial update(WmNewsMaterial wmNewsMaterial) {
        this.wmNewsMaterialDao.update(wmNewsMaterial);
        return this.queryById(wmNewsMaterial.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.wmNewsMaterialDao.deleteById(id) > 0;
    }
}
